package com.imc.core.utils;

import ognl.OgnlException;

/**
 * Created by tanweiping on 2018/7/25.
 */
/*
* 类描述：异常处理的工具类
* 开发者：tanweiping
* 创建日期：2018/8/7 10:29
*/
public class ExceptionUtil {
    /*
    * tanweiping  2018/8/7 10:30
    * 方法描述：获取根的异常
    */
    public static Throwable getRootCause(Throwable throwable) {
        while(throwable.getCause() !=null) {
            throwable=throwable.getCause();
        }
        if(throwable instanceof OgnlException && ((OgnlException)throwable).getReason() !=null) {
            return getRootCause(((OgnlException)throwable).getReason());
        }
        return throwable;
    }
}
